/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.sh.ndt.schedule.endpoint;

import com.sh.ndt.common.entity.LoginParam;
import com.sh.ndt.exception.ServiceException;
import com.sh.ndt.schedule.entity.ExamSchedule;
import com.sh.ndt.schedule.entity.ExamScheduleParam;
import com.sh.ndt.schedule.service.ScheduleService;
import com.sh.ndt.user.entity.UserDashboardDetail;
import java.util.logging.Level;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 *
 * @author Prashanth
 */
@Controller
@RequestMapping("/scheduleService")
public class ScheduleEndpoint {
        private static final Logger LOGGER = Logger.getLogger(ScheduleEndpoint.class);
        
    public ScheduleEndpoint(){
        LOGGER.debug("ScheduleEndpoint is initialized ********************** ");
    }
    
    @Autowired
    ScheduleService scheduleService;
        
        
   @RequestMapping(value = "/addNewExamSchedule",
    method = RequestMethod.POST,
    consumes = "application/xml")
    @ResponseBody
    public UserDashboardDetail addNewExamSchedule(@RequestBody ExamScheduleParam examScheduleParam) {
        
        ExamSchedule examSchedule = new ExamSchedule();
        examSchedule.setCourseId(examScheduleParam.getCourseId());
        examSchedule.setUserId(examScheduleParam.getUserId());
        examSchedule.setScheduleDate(examScheduleParam.getScheduleDate());
        
        UserDashboardDetail outcome = null;
            try {
                outcome = scheduleService.addNewSchedule(examSchedule);
            } catch (ServiceException ex) {
                ex.printStackTrace();
            }
        return outcome;
    }
    
}
